<template>
  <a-tabs v-model:activeKey="activeKey" class="smart-query-form" style="height: 280px">
    <a-tab-pane key="1" tab="打标签">
      <NewBarcodePrint ref="newBarcodePrintRef" @reloadBarcodeList="reloadBarcodeList" />
    </a-tab-pane>
  </a-tabs>
  <material-barcode-list ref="materialBarcodeListRef" @reprint="reprint" :customerData="customerData" :supplierData="supplierData" />
</template>

<script setup>
  import { onMounted, ref } from 'vue';
  import NewBarcodePrint from './components/newBarcodePrint.vue';
  import MaterialBarcodeList from '/@/views/business/whm/barcode/material-barcode-list.vue';
  import { customerInfoApi } from '/@/api/business/basic/customer/customer-info-api.js';
  import { supplierInfoApi } from '/@/api/business/basic/supplier/supplier-info-api.js';

  const activeKey = ref('1');

  const materialBarcodeListRef = ref();

  const newBarcodePrintRef = ref();

  const customerData = ref([]);
  const supplierData = ref([]);

  function reloadBarcodeList() {
    materialBarcodeListRef.value.queryData();
  }

  function reprint(data) {
    newBarcodePrintRef.value.reprint(data);
  }

  function customerAll() {
    customerInfoApi.customerAll().then((res) => {
      customerData.value = res.data;
    });
  }

  function supplierAll() {
    supplierInfoApi.all().then((res) => {
      supplierData.value = res.data;
    });
  }

  onMounted(() => {
    customerAll();
    supplierAll();
  });
</script>

<style lang="less" scoped></style>
